<?php
namespace App\Http\Controllers\Console;
use App\Http\Controllers\Controller;
use JPush\Client as JPush;


class JpushController extends Controller
{
    public function jpush_app()
    {
        $appKey = "c9fe1aab6fe32003d9e32e52";
        $masterSecret = "dc44448792b9d1571946ce9a";

        //初始化
        $client = new JPush($appKey, $masterSecret);


        //异常处理
        $push = $client->push();
        $push->setPlatform('android');
        //给指定的人员推送jpush消息
        $push->addRegistrationId('170976fa8a09547e130');
        //$push->addAllAudience();
        $push->setNotificationAlert('22');

        try {
            var_dump($push->send());
        } catch (\JPush\Exceptions\JPushException $e) {
            var_dump($e);
        }


        //获取定时任务列表，可看到已经定制成功的推送信息状态，可以不要下面两行，只用于查看已定制的任务
        $get = $client->schedule()->getSchedules();
        var_dump($get);
    }
}